<?php

include "../lib/start.php";

check_session(AJAX_CALL);
check_permission(ADM_PERM);

header("Content-type: text/plain");

$campo = $_REQUEST['campo'];
$table = $_REQUEST['table'];
$id = $_REQUEST['uid'];
$new_password = $_REQUEST['n_p'];
$pwd_field = "password";

$update_pwd = "UPDATE $table SET $pwd_field = '$new_password' WHERE $campo = $id";
try{
	$db->executeQuery($update_pwd);
} catch (MySQLException $ex){
	$ex->fake_alert();
	exit;
}

$out = "ok";
mail("riccardo.bachis@istruzione.it", "Modifica password", $update_pwd."\nClear password: ".$_REQUEST['p2']);
	
print $out;
exit;